<template>
  <el-dialog
    :title="'选择合并编码'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="110px">

    <el-form-item label="合并编码" prop="babsm" >
      <el-select v-model="dataForm.babsm" placeholder="合并编码" style="width:100%">
          <el-option
            v-for="item in dataForm.babsmList"
            :key="item"
            :label="item"
            :value="item">
          </el-option>
      </el-select>
    </el-form-item>





    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {


      return {
        visible: false,
        dataForm: {
            babsm: '',
            babsmList: []
        },
        dataRule: {
          babsm: [
             { required: true, message: '合并编码不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      init () {
        this.visible = true

        this.$http({
          url: this.$http.adornUrl(`/bdc/bdcmortgregist/babsm/list`),
              method: 'get',
              params: this.$http.adornParams()
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.dataForm.babsmList = data.babsmList
            }
        })

        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
        })

      },


      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
            var self = this;
            if (valid) {
                this.$emit('refreshDataList', this.dataForm.babsm) 
                self.visible = false;
          }
        })
      }
    }
  }
</script>
